﻿<!DOCTYPE>

<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>排故流卡创建</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
    <style type="text/css">
        .linkbutton{margin-left:20px;}
         table tr td{padding:0px 5px}
         .divLabel td{text-align: end;text-align: right;}
         #txtproductContent{width: 120px; height: 22px}
    </style>
</head>
<body>
     <!--创建排故流卡 -->
     <div id="dlg2" title="排故流卡创建" >
        <div class="easyui-panel " title="维护区域" style="padding:3px;" data-options="closable:false,minimizable:false,maximizable:false">
            <form id="CreateDealContainer" style="margin-bottom: 2px;">
               <table>
                <tr class="divLabel" style="line-height:40px">
                    <td>件号：</td>
                    <td><div id="productContent"></div>
                        <div style="display:none">
                        <input id="productId" class="easyui-textbox" name="productId" type="text"/>
                        </div>
                    </td>
                    <td>工艺规程：</td>
                    <td><input id="workFlowInfo" class="easyui-combobox" name="workFlowId" type="text" style="width: 120px; height: 22px" /></td>
                    <td>排故单号：</td>
                    <td><input id="dealFualtBill" class="easyui-textbox" name="dealFualtBill" type="text" style="width: 120px; height: 22px" readonly/></td>
                </tr>
                <tr class="divLabel" style="line-height:30px">
                    <td>主制中心：</td>
                    <td><input id="WorkcenterID" class="easyui-combobox" name="workCenterId" type="text" style="width: 180px; height: 22px" /></td>
                    <td>主制班组：</td>
                    <td><input id="TeamID" class="easyui-combobox" name="teamId" type="text" style="width: 120px; height: 22px" /></td>
                    <td>订单号：</td>
                    <td><input id="mfgOrderName" class="easyui-textbox" name="mfgOrderName" type="text" style="width: 120px; height: 22px"  /></td>
                </tr>
                <tr class="divLabel" style="line-height:40px">
                    <td>批次数量：</td>
                    <td><input id="Text15" class="easyui-numberbox" name="qty" type="text" style="width: 180px; height: 22px" /></td>
                    <td>计划开始时间：</td>
                    <td><input id="Text16" class="easyui-datebox" name="startDate" type="text" style="width: 120px; height: 22px" /></td>
                    <td>计划结束时间：</td>
                    <td><input id="Text17" class="easyui-datebox" name="endDate" type="text" style="width: 120px; height: 22px" /></td>
                </tr>
                <tr class="divLabel" style="line-height:30px">
                    <td>批次号：</td>
                    <td><input id="containerName" class="easyui-textbox" name="containerName" type="text" style="width: 180px; height: 22px" readonly /></td>
                    <td>批次类型：</td>
                    <td><input id="containerType" class="easyui-radiobutton" name="containerType" value="2" type="text" style="width: 22px; height: 22px" label="批量加工" labelPosition="after" labelAlign="left" checked/></td>
                    <td>工艺员：</td>
                    <td><input id="WorkID" class="easyui-combobox" name="workId" type="text" style="width: 120px; height: 22px" /></td>
                </tr>
            </table>
        </form> 
        </div>
        <div style="margin:20px 50px;float:right">
                <a href="javascript:void(0)" class="easyui-linkbutton linkbutton" onclick="page.CreateDealContainer();">保存</a>
        </div>
        <div id="statusMessage" style="font-size: 14px; height: 40px"></div>
     </div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ReferenceJsLib.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/array.pollyfill.js" type="text/javascript"></script>


<script type="text/javascript">
/*
创建人：longb
日期：2025-06-18
描述：排故流卡创建js
*/
var page = {
    ajaxUrl: getRootPath() + "/Ashx/DealFaultBillHandler.ashx",
    comboxUrl: getRootPath() + "/Ashx/DealFaultBillHandler.ashx",
    comboxAction:"GetProductSelect",
    dealfaultbillname:getParam("dealfaultbillname"),
    //初始化页面
    init: function () {
        page.bind();
        page.initData();
        page.ClearForm();
        $('#dealFualtBill').textbox('setValue',page.dealfaultbillname);
    },
    //页面事件绑定
    bind: function () {
        //绑定件号选择组件
        $("#productContent").selectCombox({
            search: function () {
            },
            cancel: function () { //件号取消点击事件
                 $('#productId').textbox('setValue',''); $('#workFlowInfo').combobox('clear');$('#workFlowInfo').combobox('loadData',[]);
            },
            selected: function (val, text,record) {//件号下拉选择事件
                $('#productId').textbox('setValue',text);
                page.GetWorkflowInfo(record);
                page.GenerateContainer();
            }
        });
    },
    initData: function () {
        page.post(getRootPath() + "/Ashx/ZsHandler/ZSProcessHandler.ashx",{ action: "GetWorkcenterByFactory" }, function (res) {
            $('#WorkcenterID').combobox({
                data: res,
                valueField: 'WORKCENTERID',
                textField: 'WORKCENTERNAME',
                onSelect: function (record) {
                    page.GetTeamByWorkcenter(record.WORKCENTERID);
                }
            });
        });
        page.post(null,{ action: "initData" }, function (res) {
            $('#WorkID').combobox({
                data: res.DBTable,
                valueField: 'EMPLOYEEID',
                textField: 'FULLNAME',
                onSelect: function (record) {
                }
            });
            page.factoryName=res.ReturnData.Factory;
            
        });
    },
    GetTeamByWorkcenter: function (WorkcenterID) {
        page.post(getRootPath() + "/Ashx/ApsHandler/EmployeeMaintPage.ashx?actions=getTeamList",{ action: "GetTeam", workcenterid: WorkcenterID }, function (res) {
            $('#TeamID').combobox({
                data: res.DBTable,
                valueField: 'teamid',
                textField: 'teamname',
                onSelect: function (record) {
                }
            });
        });
    },
    //查询 下拉工艺
    GetWorkflowInfo:function(val){
        var param = {
            action: "GetWorkflowSelect",
            productName:val.NAME,
            workflowName:"",
            isThisFactory:false,
        };
        page.post(getRootPath() + "/Ashx/CommonHandler.ashx",param, function (res) {
            if (res.Result) {
                $('#workFlowInfo').combobox({
                    data: res.DBTable,
                    valueField: 'WORKFLOWID',
                    textField: 'WORKFLOWNAME'
                   })
            }else{
                displayMessage(res.Message,false);
            }
        });
    },
    //创建排故流水卡
    CreateDealContainer: function () {
       var frdata = $('#CreateDealContainer').serializeArray();
        var data = {};
        $.each(frdata, function () {
            if(this.name!='MFGORDERNAME'){
                data[this.name] = this.value
            }
        });
        var strWrokflow= $('#workFlowInfo').combobox('getText');
        var workCenterText=$('#WorkcenterID').combobox('getText');
        var teamText=$('#TeamID').combobox('getText');
        data.strWrokflow=strWrokflow;
        data.productinfo=data.productId;
        data.workCenterText=workCenterText;
        data.teamText=teamText;
       var param = {
            action: "SaveDealContainer",
            data: JSON.stringify(data)
        };
        if(data.productId==''){ displayMessage("请选择【件号】再进行操作",false);return;}
        if(data.workFlowId==''){ displayMessage("请选择【工艺规程】再进行操作",false);return;}
        if(data.dealFualtBill==''){ displayMessage("请输入【排故单号】再进行操作",false);return;}
        if(data.workCenterId==''){ displayMessage("请选择【主制工区】再进行操作",false);return;}
        if(data.teamId==''){ displayMessage("请选择【主制班组】再进行操作",false);return;}
        if(data.qty==''){ displayMessage("请输入【数量】再进行操作",false);return;}
        if(data.startDate==''){ displayMessage("请输入【计划开始时间】再进行操作",false);return;}
        if(data.endDate==''){ displayMessage("请输入【计划结束时间】再进行操作",false);return;}
        if(data.workId==''){ displayMessage("请选择【主制班组】再进行操作",false);return;}
        page.post(null,param, function (res) {
            if(res.Result){page.ClearForm();}
            displayMessage(res.Message,res.Result);
        });
    },
    GenerateContainer:function(){
      var productinfo=  $('#productId').textbox('getValue');
      var dealFualtBill=  $('#dealFualtBill').textbox('getValue');
      var mfgordername=  $('#mfgOrderName').textbox('getValue');
      if(productinfo==''||dealFualtBill==''){return;}
      page.post(null,{action:'GenerateContainer',data:JSON.stringify({productinfo:productinfo,dealFualtBill:dealFualtBill,mfgorderid:"",mfgordername:mfgordername})}, function (res) {
           if(res.Result){
                $('#containerName').textbox('setValue',res.ReturnData);
           }else{
                displayMessage(res.Message, res.Result);
           }
        });
    },
    ClearForm:function(){
        $('#CreateDealContainer').form('clear');
        $("#containerType").radiobutton({checked:true});
        $('#divComboxTxt1,#divComboxSearch1').show();
        $('#divComboxSelect1,#divComboxClear1').hide();
    },
    //post数据
    post: function (url,param, callback) {
        $.ajax({
            type: "Post",
            url:url==null?page.ajaxUrl:url,
            data: param,
            cashe: false,
            async: true,
            dataType: "json",
            beforeSend: function () {
                $.messager.progress({ text: '', msg: '处理中...' });
            },
            success: function (data) {
                $.messager.progress('close');
                callback(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.messager.progress('close');
                displayMessage(XMLHttpRequest.responseText, false);
            }
        });
    }
}
$(function () {
    page.init();
});

</script>
<script src="/InSiteWebApplication/Scripts/ZsJs/selectCombox.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/ZsJs/newselectCombox.js" type="text/javascript"></script>